<?php
/* @var $this SiteController */
/* @var $model LoginForm */
/* @var $form CActiveForm  */

$this->pageTitle = Yii::app()->name . ' - Login';
$this->breadcrumbs = array(
    'Login'
);

Yii::import('ext.facebook.Facebook');
Yii::import('ext.google.Google_Client');
Yii::import('ext.google.contrib.Google_Oauth2Service');
//Yii::import('ext.twitter.TwitterOAuth');

$client = new Google_Client ();
$client->setClientId('203837015752-29f519lfk8u4fnrqmpljjmeke5rankfm.apps.googleusercontent.com');
$client->setClientSecret('CdtV1qBYhuIT7qWT1gr-sg4w');
$client->setDeveloperKey('AIzaSyAYxdSycRBJ6Q2HHabMDBnbiGICBkaFrE8');
$client->setRedirectUri(Yii::app()->createAbsoluteUrl('user/googlelogin'));
$client->setScopes("email https://www.googleapis.com/auth/userinfo.profile");
$authUrl = $client->createAuthUrl();

$facebook = new Facebook(array(
    'appId' => '128317560709307',
    'secret' => 'feb508a994e8f14286f48b74efff5291'
        ));
$params = array(
    'scope' => 'email,user_photos,user_location,user_status,publish_stream,offline_access,read_stream,photo_upload',
    'redirect_uri' => Yii::app()->createAbsoluteUrl('user/fblogin')
);

//$twitteroauth = new TwitterOAuth('c1ov9I3pAkUnRWebRug', 'Gwn4Soquts69Pj1P49YYMU99ecPpX3NoqcifKglGwA');

//$request_token = $twitteroauth->getRequestToken(Yii::app()->createAbsoluteUrl('user/twlogin'));

// Saving them into the session
//$_SESSION ['oauth_token'] = $request_token ['oauth_token'];
//$_SESSION ['oauth_token_secret'] = $request_token ['oauth_token_secret'];
//$tw_login_url = $twitteroauth->getAuthorizeURL($request_token ['oauth_token']);
?>

<h1>Login</h1>

<p>Please fill out the following form with your login credentials:</p>

<div class="form">
    <?php
    $form = $this->beginWidget('CActiveForm', array(
        'id' => 'login-form',
        'enableClientValidation' => true,
        'clientOptions' => array(
            'validateOnSubmit' => true
        )
            ));
    ?>

    <p class="note">
        Fields with <span class="required">*</span> are required.
    </p>

    <div class="row">
        <?php echo $form->labelEx($model, 'username'); ?>
        <?php echo $form->textField($model, 'username'); ?>
        <?php echo $form->error($model, 'username'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model, 'password'); ?>
        <?php echo $form->passwordField($model, 'password'); ?>
        <?php echo $form->error($model, 'password'); ?>
    </div>

    <div class="row rememberMe">
        <?php echo $form->checkBox($model, 'rememberMe'); ?>
        <?php echo $form->label($model, 'rememberMe'); ?>
        <?php echo $form->error($model, 'rememberMe'); ?>
    </div>

    <div class="row buttons">
        <?php echo CHtml::submitButton('Đăng nhập'); ?>
    </div>

    <?php $this->endWidget(); ?>
    <div>
        <a href="<?php echo $facebook->getLoginUrl($params); ?>">Login with
            Facebook</a>
    </div>
    <div>
        <a href="<?php echo $authUrl; ?>">Login with Google</a>
    </div>
    <div>
        <!--<a href="<?php // echo $tw_login_url; ?>">Login with Twitter</a>-->
    </div>
</div>
<!-- form -->
